<?php

namespace app\model;

use support\Model;

/**
 * 商品分类模型
 * 
 * @package app\model
 */
class GoodsCatModel extends Model
{
    protected $table = 'goods_cat';

    protected $primaryKey = 'id';

    /**
     * 关闭自动时间戳
     * @var bool
     */
    public $timestamps = false;

    
    protected $fillable = [
        'name',
        'fid',
        'sort',
        'status',
        'url',
    ];
    
    protected $casts = [
        'fid' => 'integer',
        'sort' => 'integer',
        'status' => 'integer',
    ];
    
    /**
     * 获取子分类
     */
    public function children()
    {
        return $this->hasMany(GoodsCatModel::class, 'fid');
    }
    
    /**
     * 获取父分类
     */
    public function parent()
    {
        return $this->belongsTo(GoodsCatModel::class, 'fid');
    }
} 